<template>
  <div>
    <el-form
      ref="form"
      size="mini"
      :model="dictSear"
      label-width="80px"
      class="search-item"
    >
      <el-form-item label="字典名称">
        <el-input v-model="dictSear.keyword"></el-input>
      </el-form-item>
      <el-form-item label="创建人">
        <el-select v-model="dictSear.createTenantId" placeholder="请选择">
          <el-option
            v-for="item in tenantList"
            :key="item.tenantId"
            :label="item.username"
            :value="item.tenantId"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="类型">
        <!--  <el-select placeholder="请选择">
          <el-option
            v-for="item in dictTypeList"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          >
          </el-option>
        </el-select> -->
      </el-form-item>
      <el-form-item label="创建时间">
        <el-date-picker
          v-model="timeArr"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="handleSearch">搜索</el-button>
        <el-button @click="handleResetSearch">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  props: {
    tenantData: {
      type: Array,
    },
    dictTypeData: {
      type: Array,
    },
  },
  watch: {
    tenantData(newVal) {
      this.tenantList = newVal;
    },
    dictTypeData(newVal) {
      this.dictTypeList = newVal;
    },
  },
  data() {
    return {
      dictSear: {},
      timeArr: [],
      tenantList: [],
      dictTypeList: [],
    };
  },
  created() {
    this.setTenant();
    this.$store.commit("dict/setDictSear");
  },
  methods: {
    // 查询字典创建人
    setTenant() {
      this.$emit("queryTenant");
    },
    // 查询字典类型
    setDictType() {
      this.$emit("");
    },
    // 搜索事件
    handleSearch() {
      this.$store.commit("dict/setDictSear",this.dictSear);
      this.$emit("search");
    },
    // 重置事件
    handleResetSearch() {
      this.resetSearchItem();
    },
    // 重置搜索条件
    resetSearchItem() {
      this.$store.commit("dict/setDictSear");
    },
  },
};
</script>

<style>
.search-item {
  display: flex;
}
</style>
